namespace SeataNet.Core.Serialization
{
    /// <summary>
    /// 序列化器接口
    /// </summary>
    public interface ISerializer
    {
        /// <summary>
        /// 序列化器类型
        /// </summary>
        SerializerType Type { get; }

        /// <summary>
        /// 序列化对象到字节数组
        /// </summary>
        byte[] Serialize<T>(T obj);

        /// <summary>
        /// 从字节数组反序列化对象
        /// </summary>
        T Deserialize<T>(byte[] data);

        /// <summary>
        /// 序列化对象到字节数组
        /// </summary>
        byte[] Serialize(object obj, Type type);

        /// <summary>
        /// 从字节数组反序列化对象
        /// </summary>
        object Deserialize(byte[] data, Type type);
    }

    /// <summary>
    /// 序列化器类型
    /// </summary>
    public enum SerializerType
    {
        /// <summary>
        /// JSON序列化器
        /// </summary>
        Json = 0,

        /// <summary>
        /// Protobuf序列化器
        /// </summary>
        Protobuf = 1,

        /// <summary>
        /// MessagePack序列化器
        /// </summary>
        MessagePack = 2
    }
}
